package com.JingYan.Thread;

import lombok.extern.slf4j.Slf4j;

/**
 * 中断标志线程
 *
 * @author Dong_Jia_Qi on 2022/6/4
 */
@Slf4j
public class InterruptCTread extends Thread{
    //多线程全保同一个属性在不同线程中同步  需要用 volatile
    public volatile boolean running = true;
    public InterruptCTread() {
    }

    public InterruptCTread(Runnable target) {
        super(target);
    }

    public InterruptCTread(ThreadGroup group, Runnable target) {
        super(group, target);
    }

    public InterruptCTread(String name) {
        super(name);
    }

    public InterruptCTread(ThreadGroup group, String name) {
        super(group, name);
    }

    public InterruptCTread(Runnable target, String name) {
        super(target, name);
    }

    public InterruptCTread(ThreadGroup group, Runnable target, String name) {
        super(group, target, name);
    }

    public InterruptCTread(ThreadGroup group, Runnable target, String name, long stackSize) {
        super(group, target, name, stackSize);
    }

    @Override
    public void run() {
        int n = 1;
        while (running){
            log.info(n+++"次执行");
        }
        log.info("线程结束");
    }
}
